﻿using System;
using System.Collections.Generic;
using System.Data.Objects;
using System.Linq;
using Omu.Awesome.Core;
using XPressify.Core;
using XPressify.Data.Helpers;

namespace XPressify.Data.CompliedQueries
{
    public class PageCompiledQueries
    {


        public static Func<Repository, Guid, Page> GetPage
        {
            get
            {
                return CompiledQuery.Compile<Repository, Guid, Page>(
                    (context, id) => context.BaseSubjects.OfType<Page>().SingleOrDefault(gr => gr.Id == id)
                    );
            }
        }

        public static Func<Repository, Guid, bool> IsPage
        {
            get
            {
                return CompiledQuery.Compile<Repository, Guid, bool>(
                    (context, id) => context.BaseSubjects.OfType<Page>().Any(gr => gr.Id == id)
                    );
            }
        }


    }
}